import { createStoreBindings } from 'mobx-miniprogram-bindings'
import { timStore } from './store/tim.js'
import Token from './model/token'

// app.js
App({
	async onLaunch() {
		const res = await Token.verifyToken()
		this.storeBindings = createStoreBindings(this, {
			store: timStore,
			fields: ['sdkReady', 'conversationList'],
			actions: ['login'],
		})
		if (res.valid) {
			await this.login()
		}

		this.storeBindings.destroyStoreBindings()
	},
})
